﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Runtime.InteropServices;
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;

namespace YT.XH.NOSE
{
    public partial class frmNSToExcel : Form
    {
        public frmNSToExcel()
        {
            InitializeComponent();
        }


        //private void ExportToExcel(DBAccess dbcon, rptParameter rptPar, System.Windows.Forms.ProgressBar proBar)
        //{
        //    proBar.Visible = true;
        //    proBar.Value = 0;
        //    Excel.Application xlApplication = new Excel.Application();
        //    Excel.Workbooks xlBooks = (Excel.Workbooks)xlApplication.Workbooks;
        //    xlBooks = (Excel.Workbooks)xlApplication.Workbooks;
        //    Excel._Workbook ThisWorkbook = (Excel._Workbook)(xlBooks.Add(Missing.Value));
        //    Excel.Worksheet xlSheet = (Excel.Worksheet)ThisWorkbook.Worksheets.Add(Type.Missing, ThisWorkbook.ActiveSheet, Type.Missing, Type.Missing);

        //    string strSQL = string.Empty;

        //    strSQL = "select * from #tmpCommissionRpt order by invdate,invno,seqno ";
        //    DataTable dtComm = dbcon.GetDataTable(strSQL);

        //    int intRow = 1;
        //    int intCol = 1;

        //    Excel.Range cell = null;

        //    Excel.Range range = xlSheet.get_Range(xlSheet.Cells[intRow, 1], xlSheet.Cells[intRow, 30]);
        //    range.MergeCells = false;
        //    range.Merge(true);
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Value2 = "Cust# from " + rptPar.strStCustNo + " to " + rptPar.strEdInvNo + ";  InvoiceNo from " + rptPar.strStInvNo + " to " + rptPar.strEdInvNo + ";  Invoice Date from " + BaseFunctions.FormatDate(CvtFunc.ToString(rptPar.datStInvDate), DateFormatOption.DateFmtMDY) + " to " + BaseFunctions.FormatDate(CvtFunc.ToString(rptPar.datEdInvDate), DateFormatOption.DateFmtMDY);


        //    #region Column Titel
        //    intRow = 2;

        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Inv#";
        //    cell.Value2 = "TPINV#";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Seq#";
        //    cell.Value2 = "TPSeq#";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Type";
        //    cell.Value2 = "TPSLRT";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    cell.Value2 = "TPAVGC";


        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Unit Price";
        //    cell.Value2 = "TPPRCE";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Quantity";
        //    cell.Value2 = "TPIQTY";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "ActFrt";
        //    cell.Value2 = "TPAFRT";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Status";
        //    cell.Value2 = "TPSTSC";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Inv Date";
        //    cell.Value2 = "TPIVDT";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Disc Date";
        //    cell.Value2 = "TPDSDT";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Due Date";
        //    cell.Value2 = "TPDUDT";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Grace Period";
        //    cell.Value2 = "TPGRAC";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Rate%";
        //    cell.Value2 = "TPCOMR";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Salesman-1";
        //    cell.Value2 = "TPIBUY";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Dollar";
        //    cell.Value2 = "TPSL1$";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Percent";
        //    cell.Value2 = "TPSL1P";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPSL1F";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Salesman-1";
        //    cell.Value2 = "TPSL2#";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Dollar";
        //    cell.Value2 = "TPSL2$";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Percent";
        //    cell.Value2 = "TPSL2P";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPSL2F";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Salesman-1";
        //    cell.Value2 = "TPSL3#";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Dollar";
        //    cell.Value2 = "TPSL3$";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Percent";
        //    cell.Value2 = "TPSL3P";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPSL3F";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Salesman-1";
        //    cell.Value2 = "TPSL4#";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Dollar";
        //    cell.Value2 = "TPSL4$";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Percent";
        //    cell.Value2 = "TPSL4P";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPSL4F";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Salesman-1";
        //    cell.Value2 = "TPSL5#";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Dollar";
        //    cell.Value2 = "TPSL5$";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Percent";
        //    cell.Value2 = "TPSL5P";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPSL5F";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Salesman-1";
        //    cell.Value2 = "TPSL6#";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Dollar";
        //    cell.Value2 = "TPSL6$";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Percent";
        //    cell.Value2 = "TPSL6P";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPSL6F";


        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Salesman-1";
        //    cell.Value2 = "TPISLM";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Dollar";
        //    cell.Value2 = "TPBUY$";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Percent";
        //    cell.Value2 = "TPBUYP";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPBUYF";


        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPMSA1";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPMSA2";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPMSA3";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPMSA4";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPMSA5";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPCST#";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPPRIC";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPWD";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPFRTP";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPLOC#";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPDISC";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPSLM";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPPDTE";


        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPDSTK";

        //    intCol++;
        //    cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //    cell.Font.Bold = true;
        //    //cell.Value2 = "Comm Flag";
        //    cell.Value2 = "TPDSAM";


        //    #endregion


        //    proBar.Maximum = dtComm.Rows.Count;
        //    foreach (DataRow drRow in dtComm.Rows)
        //    {
        //        intRow++;
        //        intCol = 1;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.NumberFormat = "@";
        //        cell.Value2 = CvtFunc.ToString(drRow["InvNo"]);


        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.NumberFormat = "@";
        //        cell.Value2 = CvtFunc.ToString(drRow["SeqNo"]);


        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.NumberFormat = "@";
        //        cell.Value2 = CvtFunc.ToString(drRow["Type"]);


        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.NumberFormat = "#,##0.00000";
        //        cell.Value2 = CvtFunc.ToString(drRow["Cost"]);


        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.NumberFormat = "#,##0.0000";
        //        cell.Value2 = CvtFunc.ToString(drRow["Price"]);


        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.NumberFormat = "#,##0.0000";
        //        cell.Value2 = CvtFunc.ToString(drRow["QtyShipInPriceUnit"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["ActFrt"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["Status"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = BaseFunctions.FormatDate(CvtFunc.ToString(drRow["InvDate"]), DateFormatOption.DateFmtMDY);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = BaseFunctions.FormatDate(CvtFunc.ToString(drRow["DiscDate"]), DateFormatOption.DateFmtMDY);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = BaseFunctions.FormatDate(CvtFunc.ToString(drRow["DueDate"]), DateFormatOption.DateFmtMDY);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["GracePeriod"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommRate"]);
        //        cell.NumberFormat = "#,##0.000";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["SlspNo"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        //cell.Value2 = CvtFunc.ToString(drRow["CommDollar"]);
        //        cell.Value2 = CvtFunc.ToString(drRow["CommAmt"]);
        //        cell.NumberFormat = "#,##0.00";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommPct"]);
        //        cell.NumberFormat = "#,##0.000";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommFlag"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["SlspNo2"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        //cell.Value2 = CvtFunc.ToString(drRow["CommDollar2"]);
        //        cell.Value2 = CvtFunc.ToString(drRow["CommAmt2"]);
        //        cell.NumberFormat = "#,##0.00";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommPct2"]);
        //        cell.NumberFormat = "#,##0.000";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommFlag2"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["SlspNo3"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        //cell.Value2 = CvtFunc.ToString(drRow["CommDollar3"]);
        //        cell.Value2 = CvtFunc.ToString(drRow["CommAmt3"]);
        //        cell.NumberFormat = "#,##0.00";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommPct3"]);
        //        cell.NumberFormat = "#,##0.000";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommFlag3"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["SlspNo4"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        //cell.Value2 = CvtFunc.ToString(drRow["CommDollar4"]);
        //        cell.Value2 = CvtFunc.ToString(drRow["CommAmt4"]);
        //        cell.NumberFormat = "#,##0.00";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommPct4"]);
        //        cell.NumberFormat = "#,##0.000";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommFlag4"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["SlspNo5"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        //cell.Value2 = CvtFunc.ToString(drRow["CommDollar5"]);
        //        cell.Value2 = CvtFunc.ToString(drRow["CommAmt5"]);
        //        cell.NumberFormat = "#,##0.00";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommPct5"]);
        //        cell.NumberFormat = "#,##0.000";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommFlag5"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["SlspNo6"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        //cell.Value2 = CvtFunc.ToString(drRow["CommDollar6"]);
        //        cell.Value2 = CvtFunc.ToString(drRow["CommAmt6"]);
        //        cell.NumberFormat = "#,##0.00";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommPct6"]);
        //        cell.NumberFormat = "#,##0.000";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CommFlag6"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["Buyer"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        //cell.Value2 = CvtFunc.ToString(drRow["BuyerCommDollar"]);
        //        cell.Value2 = CvtFunc.ToString(drRow["BuyerAmt"]);
        //        cell.NumberFormat = "#,##0.00";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["BuyerCommPct"]);
        //        cell.NumberFormat = "#,##0.000";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["BuyerCommFlag"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["Misc1Amt"]);
        //        //cell.NumberFormat = "#,##0.000";
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["Misc2Amt"]);
        //        //cell.NumberFormat = "#,##0.000";
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["Misc3Amt"]);
        //        //cell.NumberFormat = "#,##0.000";
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["Misc4Amt"]);
        //        //cell.NumberFormat = "#,##0.000";
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["Misc5Amt"]);
        //        //cell.NumberFormat = "#,##0.000";

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CustNo"]);

        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["TotalSales"]);
        //        cell.NumberFormat = "#,##0.000";
        //        //" WD char(2) not null default '', " +
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["WD"]);

        //        //" FrtCommflag char(2) not null default ''," +
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["FrtCommflag"]);

        //        //" LocNo char(6) not null default '', " +
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["LocNo"]);
        //        //" DiscAmt decimal(18,3) not null default 0," +
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["DiscAmt"]);
        //        cell.NumberFormat = "#,##0.000";
        //        //" SlspHead char(3) not null default ''," +
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["Buyer"]);
        //        //" PaidDate datetime null, " +
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = BaseFunctions.FormatDate(CvtFunc.ToString(drRow["PaidDate"]), DateFormatOption.DateFmtMDY);
        //        //" DiscTaken bit not null default 0 , " +
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToBoolean(drRow["DiscTaken"]) == false ? "N" : "Y";
        //        //" CashDiscAmt decimal(18,2) not null default 0 " +
        //        intCol++;
        //        cell = (Excel.Range)xlSheet.Cells[intRow, intCol];
        //        cell.Value2 = CvtFunc.ToString(drRow["CashDiscAmt"]);
        //        if (CvtFunc.ToDouble(cell.Value2) != 0)
        //            cell.NumberFormat = "#,##0.000";

        //        if (proBar.Value < proBar.Maximum) proBar.Value++;
        //    }
        //    xlSheet.Columns.AutoFit();
        //    xlApplication.Visible = true;
        //    proBar.Visible = false;
        //}
    }
}
